/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itsc.dawi.view;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import mx.its.dawi.BL.usuariosBLLocal;
import mx.its.dawi.model.Usuarios;

/**
 *
 * @author Martinez
 */
@ManagedBean(name = "LoginBean")
@SessionScoped
public class LoginBean {
    @EJB
    private usuariosBLLocal usuariosBL;

    private String user = "";
    private String password = "";
    private Usuarios usuario;

    /**
     * Creates a new instance of AccessBean
     */
    public LoginBean() {
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    //------------------ACTION---------------------
    public String actionProcess() {
          for (Usuarios usu : usuariosBL.obtenerUsuarios()) {
            if (user.equalsIgnoreCase(usu.getNombre()) && password.equalsIgnoreCase(usu.getAccesId())) {
            return "PrincipalMenu";
            }
        } 
            return "Login";
    }
    public String actionProcessMobile() {
        String page = "";
        for (Usuarios usu : usuariosBL.obtenerUsuarios()) {
            if (user.equalsIgnoreCase(usu.getNombre()) && password.equalsIgnoreCase(usu.getAccesId())) {
                page = "pm:viewB";
            }
        }
        return page;
    }   
    public String regresar(){
    return "pm:viewB";
    }
}
